package com.tz.farmer.service.impl;

import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.mapper.GoodsInfoMapper;
import com.tz.farmer.model.*;
import com.tz.farmer.service.WebGoodsSerice;
import com.tz.farmer.util.ResultExM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WebGoodsSericeImpl implements WebGoodsSerice {


    @Autowired
    GoodsInfoMapper goodsInfoMapper;


    @Override
    public ResultEx getGoods() {

        List<BigClassInfoVo> bigClassInfos = goodsInfoMapper.selectBigGoods();
        for (BigClassInfoVo b : bigClassInfos) {
            List<SmallClassInfoVo> smallClassInfo = goodsInfoMapper.selectSmallGoods(b.getValue());
            b.setChildren(smallClassInfo);
            for (SmallClassInfoVo s : smallClassInfo) {
                List<GoodsSelectInfoVo> goodsSelectInfo = goodsInfoMapper.selectGoodsSelect(s.getValue());
                s.setChildren(goodsSelectInfo);
            }
        }


        return ResultExM.builder().makeSuccessResult(bigClassInfos);


    }







}
